from wsgiref import headers

import requests
import re
from log.header import get_headers
from log import log

# logger = log.log('../tu/log/',__file__.split('.')[1])
# logger.info('开始爬取')
# page = 1
# while True:
#     bi_url = f'https://api.bilibili.com/pgc/season/index/result?st=1&order=3&season_version=-1&spoken_language_type=-1&area=-1&is_finish=-1&copyright=-1&season_status=-1&season_month=-1&year=-1&style_id=-1&sort=0&page={page}&season_type=1&pagesize=20&type=1'
#     ua = get_headers()
#     logger.info(f'开始爬取第{page}页---')
#     try:
#
#         response = requests.get(bi_url, headers=ua)
#         items = response.json()['data']
#         item_has_next = items['has_next']
#         item_list = items['list']
#
#         if item_has_next:
#             for item in item_list:
#                 print(item)
#             page += 1
#         else:
#             break
#     except Exception as e:
#         logger.error(e)
#
# logger.info('爬取结束')

#
#
# url = "https://api.bilibili.com/x/web-interface/wbi/index/top/feed/rcmd?&ps=10"
# res = requests.get(url,headers=get_headers())
#
# items = res.json()['data']['item']
# # print(items)
# for item in items:
#     print(item['uri'],item['title'])